home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000012_icon-group-sender _Tue Jan 7 10:18:42 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 7 Jan 1997 14:36:02 MST
  2. Message-Id: <s2d22454.000@housmtp.oceaneering.com>
  3. X-Mailer: Novell GroupWise 4.1
  4. Date: Tue, 07 Jan 1997 10:18:42 -0600
  5. From: Charlie Hethcoat <CHETHCOA@housmtp.oceaneering.com>
  6. To: gep2@computek.net, icon-group@cs.arizona.edu
  7. Subject: Another Question from the Neophyte -Reply
  8. Mime-Version: 1.0
  9. Content-Type: text/plain
  10. Content-Disposition: inline
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 1733
  14.  
  15.     The question was how best to scan for the last nonblank token,
  16. as I recall.  Using reverse() seems the most natural way to do it, if no
  17. preceding tokens are needed.  Otherwise, a normal left-to-right scan to
  18. put tokens on a list (tokenlist) would be best.  Then the last token is
  19. found in tokenlist[-1].  An Icon library routine written by Ralph Griswold
  20. does this neatly.
  21.  
  22.     But I do wonder about the implementation of reverse().  If it is a
  23. very efficient operation, I'm sure it's the best general solution.  I am
  24. unfamiliar with the Icon source, so I do not know if it moves a lot of data
  25. around, or just resets some pointers and flags to give the appearance of
  26. reversing a string.  This would be equivalent to the &direction flag that
  27. Gordon mentioned, but implicit rather than explicit.
  28.  
  29.     So if
  30.  
  31. s := "A line of text"
  32.  
  33. then is reverse(s) literally "txet fo enil A", or more like {HEY, ICONX!
  34. SCAN THE FOLLOWING DATA BACKWARDS!  pointerto(s)}?
  35.  
  36. Charlie Hethcoat
  37.  
  38. >>> <gep2@computek.net> 1997 Jan 06, 11:57am >>>
  39. >... I haven't found a good way to move
  40. backwards, besides first reversing a string and then scanning forward
  41. (which is functionally scanning backwards).
  42.  
  43. >...I did manage to find a solution, but isn't there less cumbersome way
  44. of
  45. scanning backwards than using reverse()?
  46.  
  47. There are a variety of kluges which can be used, but honestly I think that
  48. often 
  49. the most effective way simply is to use reverse()... since then
  50. everything works 
  51. in its most natural way.
  52.  
  53. There has been talk of implementing a "&direction" item which could be
  54. set 
  55. either to +1 or -1 to set the scanning direction, but nobody seems to be
  56. very 
  57. excited about that as a general feature.
  58.  
  59. Gordon Peterson
  60. http://www.computek.net/public/gep2/
  61.  
  62.  
  63.  
  64.